<template>
  <div class="product">
    <img :src="iteminfo.imgs" alt="Product Image" />
    <div class="product-details">
      <h2>{{ iteminfo.title }}</h2>
      <p>${{ iteminfo.spdj }}</p>
      <div class="quantity">
        <button :disabled="iteminfo.geshu1 <= 0" @click="iteminfo.geshu1--">-</button>
        <input type="text" v-model="iteminfo.geshu1" />
        <button @click="iteminfo.geshu1++">+</button>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { type Info } from './StuDemo4.vue'
const porps = defineProps<{
  item: Info
}>()

const iteminfo = ref<Info>(porps.item)
</script>

<style lang="scss" scoped>
.product {
  display: flex;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid #ddd;
}

.product img {
  width: 100px;
  height: 100px;
  margin-right: 20px;
  border: 2px solid slateblue;
}

.product-details {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.product-details h2 {
  margin: 0;
}

.product-details p {
  font-size: 1.2em;
  font-weight: bold;
  color: #333;
}

/* 数量调节按钮 */
.quantity {
  display: flex;
  align-items: center;
}

.quantity button {
  padding: 5px 10px;
  margin: 0 5px;
  background-color: #4caf50;
  color: white;
  border: none;
  cursor: pointer;
}

.quantity button:hover {
  background-color: #45a049;
}

.quantity input {
  width: 40px;
  text-align: center;
}
button:disabled {
  background-color: #ddd;
  cursor: not-allowed;
}
</style>
